home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1997 April / EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso / EARCD / gfx / show / MS_ShowPCX.lha / ShowPCX / display.h next >
C/C++ Source or Header  |  1996-01-14  |  2KB  |  80 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <intuition/intuition.h>
  4. #include <intuition/screens.h>
  5. #include <exec/types.h>
  6. #include <hardware/custom.h>
  7. #include <hardware/cia.h>
  8. #include <proto/intuition.h>
  9. #include <proto/graphics.h>
  10.  
  11. #define CIAAPRA 0xbfe001
  12.  
  13. #define LEFT_BUTTON 1
  14. #define RIGHT_BUTTON 2
  15.  
  16. extern struct Custom far custom;
  17. struct CIA *cia = (struct CIA *) CIAAPRA;
  18.  
  19. static void  showImage(unsigned char *buf, unsigned char *grey, int Width, int Height);
  20. UBYTE Mouse();
  21.  
  22. struct Screen *scr;
  23. struct IntuitionBase *IntuitionBase;
  24. struct GfxBase *GfxBase;
  25. struct NewScreen ns;
  26.  
  27. UBYTE Mouse()
  28. {
  29.     UBYTE result=0;
  30.     UWORD pot;
  31.     
  32.     custom.potgo=0xff00;
  33.     pot=custom.potinp;
  34.     
  35.     result+=!(cia->ciapra & 0x0040)?LEFT_BUTTON:0;
  36.     result+=!(pot&0x0400)?RIGHT_BUTTON:0;
  37.     return result;
  38. }
  39.  
  40. static void  showImage(buf, grey, Width, Height)
  41. unsigned char *buf;
  42. unsigned char *grey;
  43. int Width;
  44. int Height;
  45. {
  46.    register int i, x, y;
  47.    struct RastPort *rp;
  48.    
  49.    IntuitionBase=(struct IntuitionBase *) OldOpenLibrary("intuition.library");
  50.    if(!IntuitionBase) exit(100);
  51.  
  52.    GfxBase=(struct GfxBase *) OldOpenLibrary("graphics.library");
  53.    if(!GfxBase) exit(100);
  54.         
  55.         scr=(struct Screen *)OpenScreenTags(&ns, SA_Width, Width, SA_Height, Height,
  56.                 SA_Depth, 4, SA_DisplayID, 0x8004,
  57.                 SA_Type, CUSTOMSCREEN | AUTOSCROLL,
  58.                 SA_Overscan, OSCAN_TEXT, SA_AutoScroll, TRUE,
  59.                 SA_Quiet, 1, TAG_END);
  60.         if(scr)
  61.         {
  62.                 rp=&scr->RastPort;
  63.                 for(i=0;i<16;i++)
  64.                         SetRGB4(&scr->ViewPort, i, i, i, i);
  65.                 for(y=0;y<Height;y++)
  66.                 {
  67.                         for(x=0;x<=Width;x++)
  68.                         {
  69.                                SetAPen(rp, grey[*buf++]);
  70.                                WritePixel(rp, x, y);
  71.                         }
  72.                      if(Mouse()&RIGHT_BUTTON) break;
  73.                      }
  74.                 while(!(Mouse()&RIGHT_BUTTON));
  75.                 CloseScreen(scr);
  76.         }
  77.         CloseLibrary((struct Library *)GfxBase);
  78.         CloseLibrary((struct Library *)IntuitionBase);
  79. }
  80.